<%@page import="bean.Student"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>解除锁定</title>

</head>
<body>
	<%@include file="teacher_head.jsp"%>
	<div class="container">
		<div class="row">
			<div class="form-inline">
				<img src="../../resource/teacher.jpg" class="img-rounded imgstyle" />
				<h1>
					<strong>上机考试管理</strong>
				</h1>
			</div>
		</div>
	</div>
	<br>
	<div class="container divcontainerstyle">
		<h2>按学生查找已登录信息</h2>
		<form action="../../servlet_querystudentip_teacher">
			<div class="form-inline">
				<input type="text" name="querynumber" placeholder="学号*"
					class="form-control"> <input type="text" name="queryname"
					placeholder="姓名*" class="form-control"> <input type="text"
					name="queryclass" placeholder="班级*" class="form-control">
				<button type="submit"
					class="btn btn-primary btn-sm glyphicon glyphicon-search"
					style="display: inline;">查找</button>
			</div>
		</form>
	</div>
	<br>
	<div class="container divcontainerstyle">
		<h2>按IP地址查找已登录信息</h2>
		<form action="../../servlet_querybyip_teacher">
			<div class="form-inline">
				<input type="text" name="queryip" placeholder="IP地址*"
					class="form-control">
				<button type="submit"
					class="btn btn-primary btn-sm glyphicon glyphicon-search"
					style="display: inline;">查找</button>
			</div>
		</form>
	</div>
	<br>
	<div class="container">
		<h2>
			<strong>查找结果</strong>
		</h2>
		<table class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<td>学号</td>
					<td>姓名</td>
					<td>班级</td>
					<td>IP地址</td>
					<td>解除锁定</td>
				</tr>
			</thead>
			<tbody>

				<!-- 根据IP查找结果 -->

				<%
					if (session.getAttribute("studentip") != null) {
						Student student = (Student) (session.getAttribute("studentip"));
				%>
				<tr>
					<td><%=student.getStudentnumber()%></td>
					<td><%=student.getStudentname()%></td>
					<td><%=student.getClassroom()%></td>
					<td><%=student.getIpbinding() == null ? "未登录" : student.getIpbinding()%></td>
					<td><a href="../../servlet_unlockip_teacher?id=<%=student.getStudentid()%>"
						class="btn btn-default btn-sm glyphicon glyphicon-remove"></a>
				</tr>
				<%
					}
					session.removeAttribute("studentip");
				%>

				<!-- 根据学生信息查找结果 -->

				<%
					if (session.getAttribute("studentiplist") != null) {
						Object obj = session.getAttribute("studentiplist");
						if (obj instanceof List<?>) {
							/* 警告抑制 */
							@SuppressWarnings("unchecked")
							List<Student> studentlist = (List<Student>) (session.getAttribute("studentiplist"));

							for (Student stu : studentlist) {
				%>
				<tr>
					<td><%=stu.getStudentnumber()%></td>
					<td><%=stu.getStudentname()%></td>
					<td><%=stu.getClassroom()%></td>
					<td><%=stu.getIpbinding() == null ? "未登录" : stu.getIpbinding()%></td>
					<td><a href="../../servlet_unlockip_teacher?id=<%=stu.getStudentid()%>"
						class="btn btn-default btn-sm glyphicon glyphicon-remove"></a>
				</tr>
				<%
					}
						}
					}
				session.removeAttribute("studentip");
				%>
			</tbody>
		</table>
	</div>
</body>
</html>